Today Table





Kerry Back

Today’s values of predictors

  • Suppose we build and backtest a model based on certain predictors.
  • To decide what trades to make today, we need to know the values of the predictors today for each stock in our universe.
  • This is where the Nasdaq/Sharadar data can be useful.
  • We need to compute the predictors - ratios, growth rates, etc.

The today table

  • I coded a few of the GHZ predictors. Their values are updated every night for all stocks in the Rice SQL database.
  • The updated values are in the today table.
  • Other predictors could be coded also.

Connect to the Rice database

import pandas as pd
import pymssql
from sqlalchemy import create_engine

server = 'fs.rice.edu'
database = 'stocks'
username = 'stocks'
password = '6LAZH1'
string = "mssql+pymssql://" + username + ":" + password + "@" + server + "/" + database 

conn = create_engine(string).connect()

The today table

df = pd.read_sql(
    "select * from today where ticker in ('AAPL', 'CVX')", 
    conn
  )
df.set_index("ticker").T
ticker AAPL CVX
siccode 3571 2911
date 2023-01-13 2023-01-13
roeq 0.356601 0.07314
acc -0.062911 -0.056278
agr 0.004994 -0.001063
bm 0.020453 0.529522
ep 0.040283 0.059495
gma 0.486556 0.189862
lev 0.121929 0.379225
operprof 2.262752 0.309831
beta 1.038713 0.98459
idiovol 0.029046 0.046019
mom12m 0.047249 0.181527
mom1m -0.076684 0.043181
price 134.76 177.56
marketcap 2143778.0 343336.9
mve 14.57808 12.746467
name APPLE INC CHEVRON CORP
exchange NASDAQ NYSE
sicsector Manufacturing Manufacturing
sicindustry Electronic Computers Petroleum Refining
famasector None None
famaindustry Computers Petroleum and Natural Gas
sector Technology Energy
industry Consumer Electronics Oil & Gas Integrated
scalemarketcap 6 - Mega 6 - Mega
scalerevenue 6 - Mega 6 - Mega